#!/bin/bash

if [ ! $1 ]
then
  echo 'param1 is null *_*'
  exit 1
fi

if [ ! $2 ]
then
  echo 'param2 is null *_*'
  exit 1
fi

DIR=$(dirname $2)
FILE=$(basename $2)

if [ -s $1 ]
then
  if [ ! -d $DIR ]
  then
    mkdir $DIR  
  fi

  if [ ! -d $DIR ]
  then
    echo "$DIR create error >_<"
    exit 1
  fi

  cp -r -f $1 $2
  if [ -f $2 ]
  then
    echo "$FILE create success ^_^"
    exit 0
  else
    echo "$FILE create error >_<"
    exit 1
  fi

else
  echo "${banename $1} is empty *_*"
  exit 1
fi